package com.billing.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.billing.model.dao.ManagerUsersBeanMapper;
import com.billing.model.dao.UserBeanMapper;
import com.billing.model.entity.ManagerUsersBean;
import com.billing.model.entity.TOrganization;
import com.billing.model.entity.TUser;
import com.billing.model.entity.TUserBuffer;
import com.billing.model.entity.TUserList;
import com.billing.service.UserService;

@Service
public class UserServiceImpl implements UserService {
	@Resource
	private ManagerUsersBeanMapper managerUsersBeanMapper;
	@Resource
	private UserBeanMapper usersBeanMapper;
	
	public ManagerUsersBean getUserByNameAndPwd(String loginname, String password) {
		return managerUsersBeanMapper.getUserByNameAndPwd(loginname, password);
	}
	public List<TUser> selectTUserList(String name, String dept, Long starttime, Long endtime, String jobnumber,
			int organizationid,int currentPage, int pageSize) {
		return usersBeanMapper.selectTUserList(name, dept, starttime, endtime, jobnumber,organizationid, currentPage, pageSize);
	}
	public int selectTUserNum(String name, String dept, Long starttime, Long endtime, String jobnumber,
			int organizationid) {
		return usersBeanMapper.selectTUserNum(name, dept, starttime, endtime, jobnumber,organizationid);
	}
	public TUser selectTUserId(String id) {
		return usersBeanMapper.selectTUserId(id);
	}
	public int updateTUser(TUser user) {
		return usersBeanMapper.updateTUser(user);
	}
	public int insertTUser(TUser user) {
		return usersBeanMapper.insertTUser(user);
	}
	
	public int insertTUserList(TUserList users) { 
		return usersBeanMapper.insertTUserList(users);
	}
	
	public int deleteTUser(int id) {
		return usersBeanMapper.deleteTUser(id);
	}
	public TUser getTUser(String loginname, String password) {
		return usersBeanMapper.getTUser(loginname, password);
	}
	public TUser selectTUserPayId(String id) {
		return usersBeanMapper.selectTUserPayId(id);
	}
	public TUser getTUserById(String id) {
		return usersBeanMapper.getTUserById(id);
	}
	@Override
	public TUser getTSubsidyById(String id) {
		return usersBeanMapper.getTSubsidyById(id);
	}
	@Override
	public boolean userMobileIsExist(String mobile,String orgid,String userid) {
		int count = usersBeanMapper.countMobileOnOrgid(mobile, orgid,userid);
		int count2 = usersBeanMapper.countMobileNotArchiving(mobile, orgid);
		if(count > 0 || count2 > 0){
			return true;
		}
		return false;
	}
	@Override
	public boolean userIdcardIsExist(String idcard, String orgid,String userid) {
		int count = usersBeanMapper.countIdcardOnOrgid(idcard, orgid,userid);
		int count2 = usersBeanMapper.countIdcardNotArchiving(idcard, orgid);
		if(count > 0 || count2 > 0){
			return true;
		}
		return false;
	}
	@Override
	public List<TUser> selectTUserLoginnameList(String loginname,
			int organizationid, int currentPage, int pageSize) {
		return usersBeanMapper.selectTUserLoginnameList(loginname, organizationid, currentPage, pageSize);
	}
	@Override
	public int selectTUserLoginnameNum(String loginname, int organizationid) {
		return usersBeanMapper.selectTUserLoginnameNum(loginname, organizationid);
	}
	@Override
	public int updateExamineStatus(String userId, String examineStatus) {
		return usersBeanMapper.updateExamineStatus(userId, examineStatus);
	}
	@Override
	public int updateJobStatus(String userId, String jobStatus) {
		return usersBeanMapper.updateJobStatus(userId, jobStatus);
	}
	@Override
	public int updateByBuffer(TUserBuffer userBuffer) {
		return usersBeanMapper.updateByBuffer(userBuffer);
	}
	@Override
	public int updateArchivingTime(String id, long atime) {
		return usersBeanMapper.updateArchivingTime(id,atime);
	}
	@Override
	public int updatePassword(String newPassword,String oldPassword) {
		return usersBeanMapper.updatePassword(newPassword,oldPassword);
	}
	@Override
	public List<TOrganization> getOrganization(String userid) {
		return usersBeanMapper.getOrganization(userid);
	}
	@Override
	public TUser getPhoneNumber(String mobile) {
		return usersBeanMapper.getPhoneNumber(mobile);
	}
	@Override
	public int updatearchivingtime(String mobile) {
		return usersBeanMapper.updatearchivingtime(mobile);
	}
}
